﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_TaskLayout.cshtml";
}

@model List<HYBY.Task.DataEntity.TAModularEntity>

<style>
    .clgxs-left-title li {
        line-height: 26px;
    }

    .wid30 {
        width: 20%;
    }

    .wid10 {
        width: 10%;
    }

    .clgxs-left {
        width: 98%;
    }

    .clgxs-left-title {
        height: 60px;
    }

    .jm_clgxs-left-banner ul:hover {
        background-color: #bbddc2;
        border-radius: 3px;
    }

    .clgxs-left-banner1 ul {
        line-height: 30px;
    }

    .jm_open-icons, .jm_btn_two, .jm_btn_three, .jm_btn_fore {
        padding-top: 15px;
    }

    .close-icons, .open-icons {
        margin-top: 9px;
    }
</style>

<div id="main_content" style="margin-left: 0px;">

    <div class="main-wrapper-content">
        <div class="breadcrumb" style="margin-top: 71px;">
            <a href="javascript:;">首页</a> >
            <a href="javascript:;">已完成任务</a>
        </div>

        <div class="clgxs-left-main">
            <!--左边部分开始-->
            <div class="clgxs-left-title">
                <ul class="clear">
                    <li class="wid30">
                        @*<input type="button" id="AddProdute" value="添加产品线" class="md-button ml5 fl jm_md_button jm_but_color">*@
                        <span>产品线：<span class="cfd0101">8</span></span>
                    </li>
                    <li class="wid10">系统</li>
                    <li class="wid10">模块</li>
                    <li class="wid10">科目</li>
                    <li class="wid10">研发</li>
                    <li class="wid10">UED</li>
                    <li class="wid10">开发</li>
                    <li class="wid10">测试</li>
                    <li class="wid10">操作</li>
                </ul>
                <ul class="clear">
                    <li class="wid30">&nbsp;</li>
                    <li class="wid10">@Model.Where(w => w.ProductId == 2).Count()</li>
                    <li class="wid10">@Model.Where(w => w.ProductId == 3).Count()</li>
                    <li class="wid10">@Model.Where(w => w.ProductId == 4).Count()</li>
                    <li class="wid10">&nbsp;</li>
                    <li class="wid10">&nbsp;</li>
                    <li class="wid10">&nbsp;</li>
                    <li class="wid10">&nbsp;</li>
                </ul>
            </div>

            <div class="clgxs-left-caidan-body">
                <div class="clgxs-left-banner jm_clgxs-left-banner" id="cdbox">
                    <!--菜单开始-->

                    @{

                        var index = 1;

                        foreach (KeyValuePair<int, string> item in ViewBag.ProductId)
                        {
                            var temp = Model.Where(w => w.ProductId == item.Key && w.ModularTypeId == 1).FirstOrDefault();

                            <div class="clgxs-left-banner1  contentbox0">
                                <ul class="clear">
                                    <li class="wid30 teAlLe">
                                        <span class="open-icons btn-one"></span>
                                        <span class="jm_open-icons"></span>
                                        <b class="TreeLevel1">0@(index++)、@item.Value</b>
                                    </li>
                                    <li class="wid10 ziduan1-1">@Model.Where(w => w.ProductId == item.Key && w.ProductId == 2).Count()</li>
                                    <li class="wid10 ziduan1-2">@Model.Where(w => w.ProductId == item.Key && w.ProductId == 3).Count()</li>
                                    <li class="wid10 ziduan1-3">@Model.Where(w => w.ProductId == item.Key && w.ProductId == 4).Count()</li>
                                    <li class="wid10 ziduan1-4">@(temp == null ? "未匹配" : temp.ResearchHead)</li>
                                    <li class="wid10 ziduan1-4">@(temp == null ? "未匹配" : temp.UEDHead)</li>
                                    <li class="wid10 ziduan1-4">@(temp == null ? "未匹配" : temp.DevelopmentHead)</li>
                                    <li class="wid10 ziduan1-4">@(temp == null ? "未匹配" : temp.TestHead)</li>
                                    <li class="wid10 ziduan1-4">
                                        <input type="button" class="jm_table_btn fl jm_but_color jm_update" data-id="@(temp == null ? 0 : temp.ID)" value="修改">
                                        <input type="button" class="jm_table_btn fl jm_but_color jm_add_btn" data-id="@(temp == null ? 0 : temp.ID)" data-type="1" value="添加">
                                    </li>
                                    @*<li class="wid10 ziduan1-4">@(temp == null ? "" : temp.ApplicationHead)</li>*@
                                </ul>

                                @{
                                    var nIndex = 1;

                                    foreach (KeyValuePair<int, string> nItem in ViewBag.ProductModelId)
                                    {
                                        var systemp = Model.Where(w => w.ProductId == item.Key && w.ModularName.Trim() == nItem.Value.Trim()).FirstOrDefault();

                                        if (systemp != null)
                                        {
                                            <div class="clgxs-left-banner2 disNon" style="display: none;">
                                                <ul class="clear">
                                                    <li class="wid30 teAlLe">
                                                        <span class="open-icons openclose btn-two close-icons"></span>
                                                        <span class="jm_btn_two"></span>
                                                        <b class="TreeLevel2" shortname="E01">0@(nIndex++)、@nItem.Value</b>
                                                    </li>
                                                    <li class="wid10 ziduan1-1">&nbsp;</li>
                                                    <li class="wid10 ziduan1-2">@Model.Where(w => w.ModularTypeId == 3).Count()</li>
                                                    <li class="wid10 ziduan1-3">@Model.Where(w => w.ModularTypeId == 4).Count() </li>
                                                    <li class="wid10 ziduan1-4">@(systemp == null ? "未匹配" : systemp.ResearchHead)</li>
                                                    <li class="wid10 ziduan1-4">@(systemp == null ? "未匹配" : systemp.UEDHead)</li>
                                                    <li class="wid10 ziduan1-4">@(systemp == null ? "未匹配" : systemp.DevelopmentHead)</li>
                                                    <li class="wid10 ziduan1-4">@(systemp == null ? "未匹配" : systemp.TestHead)</li>
                                                    @*<li class="wid10 ziduan1-4">@(systemp == null ? "" : systemp.ApplicationHead)</li>*@
                                                    <li class="wid10 ziduan1-4"></li>
                                                    <li class="wid10 ziduan1-4">
                                                        <input type="button" class="jm_table_btn fl jm_but_color jm_update" data-id="@(systemp == null ? 0 : systemp.ID)" value="修改">
                                                        <input type="button" class="jm_table_btn fl jm_but_color jm_add_btn" data-id="@(systemp == null ? 0 : systemp.ID)" data-type="1" value="添加">
                                                    </li>
                                                </ul>
                                                @{
                                                    var modelList = Model.Where(w => systemp != null && w.FatherId == systemp.ID);

                                                    var modelIndex = 1;

                                                    foreach (var modelItem in modelList)
                                                    {
                                                        <div class="clgxs-left-banner3 disNon" style="display: none;">
                                                            <ul class="clear">
                                                                <li class="wid30 teAlLe">
                                                                    <span class="open-icons openclose btn-three close-icons"></span>
                                                                    <span class="jm_btn_three"></span>
                                                                    <b class="TreeLevel3">@(modelIndex.ToString().Length >= 2 ? modelIndex.ToString() : "0" + modelIndex)、@modelItem.ModularName</b>
                                                                </li>
                                                                <li class="wid10 ziduan3-1">&nbsp;</li>
                                                                <li class="wid10 ziduan3-2">&nbsp;</li>
                                                                <li class="wid10 ziduan3-2">&nbsp;</li>
                                                                <li class="wid10 ziduan3-2">@(modelItem == null ? "未匹配" : modelItem.ResearchHead)</li>
                                                                <li class="wid10">@(modelItem == null ? "未匹配" : modelItem.UEDHead)</li>
                                                                <li class="wid10">@(modelItem == null ? "未匹配" : modelItem.DevelopmentHead)</li>
                                                                <li class="wid10">@(modelItem == null ? "未匹配" : modelItem.TestHead)</li>
                                                                <li class="wid10 ">
                                                                    <input type="button" class="jm_table_btn fl jm_but_color jm_update" data-id="@(modelItem == null ? 0 : modelItem.ID)" value="修改">
                                                                    <input type="button" class="jm_table_btn fl jm_but_color jm_add_btn" data-id="@(modelItem == null ? 0 : modelItem.ID)" data-type="1" value="添加">
                                                                </li>
                                                            </ul>
                                                            @{
                                                                //科目
                                                                var subjectList = Model.Where(w => modelItem != null && w.FatherId == modelItem.ID);

                                                                var subjectIndex = 1;

                                                                foreach (var subjectItem in subjectList)
                                                                {
                                                                    <div class="clgxs-left-banner4 disNon" style="display: none;">
                                                                        <ul class="clear">
                                                                            <li class="wid30 teAlLe">
                                                                                <span class="jm_btn_fore openclose"></span>
                                                                                <b class="TreeLevel4">@(subjectIndex.ToString().Length >= 2 ? subjectIndex.ToString() : "0" + subjectIndex)、@subjectItem.ModularName</b>
                                                                            </li>
                                                                            <li class="wid10 ziduan3-1">&nbsp;</li>
                                                                            <li class="wid10 ziduan3-2">&nbsp;</li>
                                                                            <li class="wid10 ziduan3-2">&nbsp;</li>
                                                                            <li class="wid10 ziduan3-2">@(subjectItem == null ? "未匹配" : modelItem.ResearchHead)</li>
                                                                            <li class="wid10">@(subjectItem == null ? "未匹配" : modelItem.UEDHead)</li>
                                                                            <li class="wid10">@(subjectItem == null ? "未匹配" : modelItem.DevelopmentHead)</li>
                                                                            <li class="wid10">@(subjectItem == null ? "未匹配" : modelItem.TestHead)</li>
                                                                        </ul>
                                                                    </div>
                                                                }

                                                            }


                                                        </div>
                                                                }


                                                }


                                            </div>
                                                                    }
                                                                }
                                }


                            </div>
                                                                }


                    }


                </div><!--整体菜单结束-->
            </div><!--出现滚动条出现的结束-->
        </div>
    </div>

</div>



<div class="loading hide"></div>

<!--弹出层  遮罩  开始-->
<div class="alertMask"></div>

<!--添加人员弹出层-->
<div class="alertBox jm_alert1" id="repulseBox">
    <div class="alertTitle j_alertHeight">
        <p>添加产品线</p>
        <span class="alertClose close"></span>
    </div>
    <div class="alertCon jm_alertCon">
    </div>
    <div class="alertFoot">
        <div class="dis_il_block">
            <a href="javascript:" class="buttonh26 button-c46a1fe table-btn fl mr10 jm_but_color" id="saveModel" style="min-width: 40px;">确定</a>
        </div>
    </div>
</div>


@section FootScript{

    <script type="text/javascript">
        $(function () {

            //新建/修改
            @*$("#AddProdute").click(function () {
                rxued.alert.jAlert(".jm_alert1", 800);
                $(".jm_alertCon").load("@Url.Action("AddOrUpdate",new { id=0})");
            });*@

            $(".jm_update").click(function () {
                rxued.alert.jAlert(".jm_alert1", 800);
                $(".jm_alertCon").load("@Url.Action("AddOrUpdate")", { dataid: $(this).attr("data-id"), type: 2 });
            });

            $(".jm_add_btn").click(function () {
                rxued.alert.jAlert(".jm_alert1", 800);
                $(".jm_alertCon").load("@Url.Action("AddOrUpdate")", { dataid: $(this).attr("data-id"), type: 1 });
            });


            //////////////////////////  树    形     ///////////////////////////////////

            //计算滚动条的函数
            function mainScroll() {
                var winH = $(window).height();
                //右侧的高度
                $(".clgxs-left-caidan-body").css("height", winH - 33 - $(".clgxs-left-header").outerHeight(true) - $(".clgxs-left-title").outerHeight(true) + "px")
                //右侧的高度
                $(".clgxs-right").css("height", winH - 45 + "px")
                //左侧右侧宽度

                //jm   $(".clgxs-left-title ul").css("width", $(".clgxs-left-banner1").outerWidth() + "px")
            }

            //菜单显示
            //左侧一级菜单的控制
            $("#cdbox,#cdbox2").on("click", ".btn-one", function () {
                if ($(this).parents("ul").next(".clgxs-left-banner2").css("display") == "none") {
                    $(".clgxs-left-banner1").find("div").css("display", "none")
                    $(".clgxs-left-banner1").find(".close-icons").removeClass("close-icons")
                    $(this).parents("ul").nextAll(".clgxs-left-banner2").css("display", "block");
                    $(this).addClass("close-icons")
                } else {
                    $(this).parents("ul").parent().find("div").css("display", "none")
                    $(this).removeClass("close-icons")
                }
            });


            //左侧二级菜单的控制
            $("#cdbox,#cdbox2").on("click", ".btn-two", function () {
                if ($(this).parents("ul").next(".clgxs-left-banner3").css("display") == "none") {
                    $(".clgxs-left-banner2").find("div").css("display", "none")
                    $(".clgxs-left-banner2").find(".openclose").removeClass("close-icons")
                    $(this).parents("ul").nextAll(".clgxs-left-banner3").css("display", "block")
                    $(this).addClass("close-icons")
                } else {
                    $(this).parents("ul").parent().find("div").css("display", "none")
                    $(this).removeClass("close-icons")
                }
            })

            //左侧三级菜单的控制
            $("#cdbox,#cdbox2").on("click", ".btn-three", function () {
                if ($(this).parents("ul").next(".clgxs-left-banner4").css("display") == "none") {
                    $(".clgxs-left-banner3").find("div").css("display", "none")
                    $(".clgxs-left-banner3").find(".openclose").removeClass("close-icons")
                    $(this).parents("ul").nextAll(".clgxs-left-banner4").css("display", "block")
                    $(this).addClass("close-icons")
                } else {
                    $(this).parents("ul").parent().find("div").css("display", "none")
                    $(this).removeClass("close-icons")
                }
            })
            //左侧四级菜单的控制
            $("#cdbox,#cdbox2").on("click", ".btn-fore", function () {
                if ($(this).parents("ul").next(".clgxs-left-banner5").css("display") == "none") {
                    $(".clgxs-left-banner4").find("div").css("display", "none")
                    $(".clgxs-left-banner4").find(".openclose").removeClass("close-icons")
                    $(this).parents("ul").nextAll(".clgxs-left-banner5").css("display", "block")
                    $(this).addClass("close-icons")
                } else {
                    $(this).parents("ul").parent().find("div").css("display", "none")
                    $(this).removeClass("close-icons")
                }
            })


            $("#saveModel").click(function () {

                var obj = {};


                obj.productId = $(".btn_chanpin.jm_but_btn_cur").attr("data-id");

                obj.Id = $("#Id").val();
                obj.FatherId = $("#FatherId").val();

                obj.ResearchHeadCard = $("#dSelectOption").val();
                obj.ResearchHead = $("#dSelectOption option:selected").text();

                obj.UEDHeadCard = $("#uSelectOption").val();
                obj.UEDHead = $("#uSelectOption option:selected").text();

                obj.DevelopmentHeadCard = $("#dSelectOption").val();
                obj.DevelopmentHead = $("#dSelectOption option:selected").text();

                obj.TestHeadCard = $("#tSelectOption").val();
                obj.TestHead = $("#tSelectOption option:selected").text();

                obj.ModularTypeId = $("#ModularTypeId").val();


                if (obj.ModularTypeId == "0") {
                    obj.ModularTypeId = $(".btn_bumen.jm_but_btn_cur").attr("data-id");
                }

                if (!obj.ModularTypeId) {
                    alert("请选择阶段");
                    return false;
                }



                if (obj.ModularTypeId == 2) {
                    obj.ModularName = $("#modelList option:selected").text();

                }
                else {
                    obj.ModularName = $("#ModularName").val();
                }



                $.ajax({
                    url: "@Url.Action("Save")",// 跳转到 action
                    data: obj,
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        if (data.isSuccess) {
                            window.location.reload(true);
                        } else {
                            alert("操作失败");
                        }
                    },
                    error: function () {
                        // view("异常！");
                        alert("异常！");
                    }
                });

            });

        })
    </script>
}

